package com.mlc.api.controller;

import com.mlc.core.dto.RequestDto;
import com.mlc.core.service.PlaylistsService;
import com.alibaba.fastjson.JSONObject;
import com.mlc.utils.commom.ResponseResult;
import com.mlc.utils.enums.CodeType;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author FireWang
 * @date 2022/03/14 22:43:06
 */
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/playlist")
public class PlaylistsController {
    private PlaylistsService playlistsService;
    private static JSONObject result;

    /**
     * 获取全部数据列表
     *
     * @return
     */
    @GetMapping
    public JSONObject getPlayList(RequestDto playListDto) {
        try {
            List playlistsList = playlistsService.getPlayListByCondition(playListDto);
            result = ResponseResult.build(CodeType.SUCCESS, "成功！");
            result.put("list", playlistsList);
        } catch (Exception e) {
            log.error(e.getMessage());
            result = ResponseResult.build(CodeType.FAIL, "失败：" + e.getMessage());
        }
        return result;
    }
}